define(function(require, exports, module){
	require("resource/js/easyui/themes/icon.css");
	require("resource/js/easyui/easyloader.js");
	require("resource/js/component/rules.js");
	var AJAX = require("resource/js/component/ajax.js");
	var EUtil = require("resource/js/component/easyutil.js");
	var ECombobox = require("resource/js/component/easycombobox.js");
	var userModel = undefined;
	var Obj = window.loadI18n('base/user');
	var dgutil = undefined;
	var config = {
			column:[[
			         {field:'userId',title:""+Obj.get('base.common.success.user')+"ID",width:50,align:'center',height:50,hidden:true},
			         {field:'userName',title:""+Obj.get('base.common.success.user')+ Obj.get('base.common.success.name')+"",width:50,align:'center',height:50},
			         {field:'logintime',title:""+Obj.get('base.user.login')+ Obj.get('base.common.success.time')+"",width:80,align:'center',height:50},
			         {field:'exittime',title:""+Obj.get('base.common.success.Cancel')+ Obj.get('base.common.success.time')+"",width:80,align:'center',height:50},
			         {field:'ip',title:"IP"+Obj.get('base.common.success.address')+"",width:60,align:'center',height:50},
			         {field:'mac',title:"MAC"+Obj.get('base.common.success.address')+"",width:60,align:'center',height:50,hidden:true},
			         {field:'exitflag',title:""+Obj.get('base.common.success.Cancel')+ Obj.get('base.common.success.address')+"",width:50,align:'center',height:50},
			         {field:'deviceType',title:""+Obj.get('base.common.success.Devicetype')+"",width:300,align:'center',height:50,formatter: function (value, row) {
							 if(value == undefined || value ==''){
								 return '';
							 }
							 var val=value.length > 110?value.substring(0, 110)+'...':value;
							 return "<span title='" + value + "'>" + val + "</span>";
						 }},
			         {field:'memo',title:""+Obj.get('base.common.success.note')+"",width:100,align:'center',height:50,hidden:true}
			         ]]
	}
	var datagridconfig = undefined;
	
	ECombobox.create({
		url:BASEPATH+"/base/authoriza/basecode/getType.htm", param:{checkeds:"login_exit_flag"}
	});

	function initpage(){
		dgutil = new EUtil.ajaxDataGrid(datagridconfig);
		ECombobox.init({ ele:"#exitflag", grouptype:"login_exit_flag" });
		
		$("*").keydown(function(e){
			var keyEvent;
			if(e.keyCode==8) {
				var d=e.srcElement||e.target;
				if(d.tagName.toUpperCase()=="INPUT"||d.tagName.toUpperCase()=="TEXTAREA"||d.tagName.toUpperCase()=="PASSWORD"){
					 keyEvent=d.readOnly||d.disabled;   
				}else{
					keyEvent=true;
				}
			}else{
				keyEvent=false;
			}
			if(keyEvent){   
	            e.preventDefault();   
	        }   
		});
	}
	
	module.exports = {
		init:function(){
			var buttons ={ 
					title:{
						_class:"",
						text:""+Obj.get('base.common.success.Loginlog')+""
					},
					btn:[{
				    	iconCls: 'icon-search',
				    	url:'/base/authoriza/login/queryLoginLog.htm',
				    	text:""+Obj.get('base.common.success.query')+"",
						addClass:'l-btn-display',
				    	handler: function(){
				    		var stime = $('#logintimeStart').datetimebox('getValue'), 
			    				etime = $('#logintimeEnd').datetimebox('getValue');
				    		if (stime > etime) {
								$.messager.show({title:""+Obj.get('base.common.success.Systemprompt')+"",msg:""+Obj.get('base.common.success.loginless')+""});
								return;
				    		}
				    		stime = $('#exittimeStart').datetimebox('getValue'), 
		    				etime = $('#exittimeEnd').datetimebox('getValue');
				    		if (stime > etime) {
								$.messager.show({title:""+Obj.get('base.common.success.Systemprompt')+"",msg:""+Obj.get('base.common.success.cancelless')+""});
								return;
				    		}
				    		dgutil.pager(1);
			    		}
					}]
				};
			datagridconfig = {
					fitColumns:true,
					singleSelect:false,
					striped:true,
					autoRowHeight:true,
					toolbar:buttons,
					columns:config.column,
					eid:"dg", 
					url:BASEPATH+'/base/authoriza/login/queryLoginLog.htm',
					args:"searchform"
			};
			using(["datagrid","parser","messager","dialog","combobox"],function(){
				initpage();
			});
		}
	}
});